package org.hs.phd.common.simpleplayer.filter;

import org.hs.phd.common.simpleplayer.ImageSequenceFrame;
import org.hs.phd.common.simpleplayer.PlayerFilter;

import com.googlecode.javacv.cpp.opencv_core;

public class FlipFilter implements PlayerFilter {

	private final FlipType flipType;

	public enum FlipType {NONE, FLIP_AROUND_X_AXIS, FLIP_AROUND_Y_AXIS, FLIP_AROUND_BOTH_AXES}

    public FlipFilter(FlipType flipType){
		this.flipType = flipType;
	}
	

	@Override
	public void filter(ImageSequenceFrame input) {
		if( flipType != FlipType.NONE ){	
			int flipCode = flipType == FlipType.FLIP_AROUND_BOTH_AXES ? -1 : (flipType == FlipType.FLIP_AROUND_X_AXIS ? 0 : 1);
			opencv_core.cvFlip(input.getFrameImage(), null, flipCode);
		}
	}

}
